package com.lc.qianrenshiye.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import com.lc.qianrenshiye.BaseApplication;
import com.lc.qianrenshiye.R;
import com.lc.qianrenshiye.activity.ConfirmOrderActivity;
import com.lc.qianrenshiye.adapter.OrderAdapter;
import com.lc.qianrenshiye.conn.OrderListPost;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.scale.ScaleScreenHelperFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/2.
 */
public class NotPayDialog extends Dialog{

    private ListView not_pay_order_lv;
    public List<OrderListPost.OrderEntity> lists = new ArrayList<>();
    private OrderAdapter adapter;

    private OrderListPost orderListPost = new OrderListPost(new AsyCallBack<OrderListPost.OrderListEntity>() {
        @Override
        public void onSuccess(String toast, int type, OrderListPost.OrderListEntity orderListEntity) throws Exception {

            lists.addAll(orderListEntity.orderEntityList);

            adapter.notifyDataSetChanged();
        }

        @Override
        public void onFail(String toast, int type) throws Exception {


        }
    });

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ScaleScreenHelperFactory.getInstance().loadView((ViewGroup) findViewById(R.id.not_pay_dialog_ll));
        getWindow().setGravity(Gravity.TOP);
    }


    public NotPayDialog(Context context, OrderAdapter.PayOrContinue payOrContinue) {
        super(context, R.style.CutPriceDialog);

        setContentView(R.layout.fragment_not_pay_order);

        ((TextView) findViewById(R.id.not_pay_order_title_tv)).setText(context.getResources().getString(R.string.not_pay_order_title_order));

        not_pay_order_lv = (ListView) findViewById(R.id.not_pay_order_lv);

        not_pay_order_lv.setAdapter(adapter = new OrderAdapter(context, lists, payOrContinue));

        orderListPost.sid = BaseApplication.BasePreferences.readShopId();
        orderListPost.uid = BaseApplication.BasePreferences.readUserId();
        orderListPost.pay = "-1";
        orderListPost.time1 = "";
        orderListPost.time2 = "";

        orderListPost.execute(context, false);

        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                switch (v.getId()) {

                    case R.id.not_pay_cancle_rl:

                        dismiss();

                        break;
                }
            }
        };

        findViewById(R.id.not_pay_cancle_rl).setOnClickListener(listener);

    }


}
